import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/layout'

Vue.use(Router)

const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    name: 'Login',
    hidden: true,
    component: () => import('@/views/login/index'),
    meta: { title: '登录' }
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        component: () => import('@/views/dashboard/index'),
        name: 'Dashboard',
        meta: { title: '主页', icon: 'home', affix: true }
      }
    ]
  },
  {
    path: '/user',
    component: Layout,
    name: 'UserPage',
    meta: {
      title: '用户管理',
      icon: 'users'
    },
    children: [
      {
        // 路径：/student/list
        path: 'student/list',
        // 组件：@/views/user/student/list
        component: () => import('@/views/user/student/list'),
        // 路由名称：UserStudentPageList
        name: 'UserStudentPageList',
        // 元数据：包含标题和是否缓存的信息
        meta: { title: '学生列表', noCache: true }
      },

      {
        path: 'student/edit',
        component: () => import('@/views/user/student/edit'),
        name: 'UserStudentEdit',
        meta: { title: '学生编辑', noCache: true, activeMenu: '/user/student/list' },
        hidden: true
      },
      {
        path: 'admin/list',
        component: () => import('@/views/user/admin/list'),
        name: 'UserAdminPageList',
        meta: { title: '管理员列表', noCache: true }
      },
      {
        path: 'admin/edit',
        component: () => import('@/views/user/admin/edit'),
        name: 'UserAdminEdit',
        meta: { title: '管理员编辑', noCache: true, activeMenu: '/user/admin/list' },
        hidden: true
      }
    ]
  },
  {
    path: '/group',
    component: Layout,
    name: 'GroupPage',
    meta: {
      title: '群组管理',
      icon: 'group'
    },
    children: [
      {
        // 路径：/student/list
        path: 'groups/list',
        // 组件：@/views/user/student/list
        component: () => import('@/views/group/groups/list'),
        // 路由名称：UserStudentPageList
        name: 'groupList',
        // 元数据：包含标题和是否缓存的信息
        meta: { title: '群组列表', noCache: true }
      },

      {
        path: 'groups/edit',
        component: () => import('@/views/group/groups/edit'),
        name: 'UserStudentEdit',
        meta: { title: '群组编辑', noCache: true, activeMenu: '/group/groups/list' },
        hidden: true
      },
      {
        path: 'groups/userList',
        component: () => import('@/views/group/groups/userList.vue'),
        name: 'UserAdminPageList',
        meta: { title: '群组成员列表', noCache: true },
        hidden: true
      },
      {
        path: 'groupUsers/edit',
        component: () => import('@/views/group/groupUsers/edit'),
        name: 'UserAdminEdit',
        meta: { title: '查看成员详情', noCache: true, activeMenu: '/group/groupUsers/list' },
        hidden: true
      }
    ]
  },
  {
    path: '/exam',
    component: Layout,
    name: 'ExamPage',
    meta: {
      title: '卷题管理',
      icon: 'exam'
    },
    children: [
      {
        path: 'paper/list',
        component: () => import('@/views/exam/paper/list'),
        name: 'ExamPaperPageList',
        meta: { title: '试卷列表', noCache: true }
      },
      {
        path: 'paper/edit',
        component: () => import('@/views/exam/paper/edit'),
        name: 'ExamPaperEdit',
        meta: { title: '试卷编辑', noCache: true, activeMenu: '/exam/paper/list' },
        hidden: true
      },
      {
        path: 'question/list',
        component: () => import('@/views/exam/question/list'),
        name: 'ExamQuestionPageList',
        meta: { title: '题目列表', noCache: true }
      },
      {
        path: 'paper/edit/question',
        component: () => import('@/views/exam/question/edit/question-type.vue'),
        name: 'questionTypeInfo',
        meta: { title: '题目编辑', noCache: true, activeMenu: '/exam/question/list' },
        hidden: true,
        children: [
          {
            path: 'question/edit/singleChoice',
            component: () => import('@/views/exam/question/edit/single-choice'),
            name: 'singleChoicePage',
            meta: { title: '选择题编辑', noCache: true, activeMenu: '/exam/question/edit/question-type' },
            hidden: true
          },
          {
            path: 'question/edit/gapFilling',
            component: () => import('@/views/exam/question/edit/gap-filling'),
            name: 'gapFillingPage',
            meta: { title: '完形填空题编辑', noCache: true, activeMenu: '/exam/question/edit/question-type' },
            hidden: true
          },
          {
            path: 'question/edit/readingComprehension',
            component: () => import('@/views/exam/question/edit/reading-comprehension.vue'),
            name: 'readingComprehension',
            meta: { title: '阅读理解题编辑', noCache: true, activeMenu: '/exam/question/edit/reading-comprehension' },
            hidden: true
          },
          {
            path: 'question/edit/shortAnswer',
            component: () => import('@/views/exam/question/edit/short-answer.vue'),
            name: 'shortAnswerPage',
            meta: { title: '分析题编辑', noCache: true, activeMenu: '/exam/question/edit/question-type' },
            hidden: true
          },
          {
            path: 'question/edit/translationQuestion',
            component: () => import('@/views/exam/question/edit/translation_question.vue'),
            name: 'translationQuestion',
            meta: { title: '翻译题编辑', noCache: true, activeMenu: '/exam/question/edit/question-type' },
            hidden: true
          }
        ]
      },
      {
        path: 'question/edit/type',
        component: () => import('@/views/exam/question/list'),
        name: 'questionType',
        hidden: true
      }
    ]
  },
  // {
  //   path: '/task',
  //   component: Layout,
  //   name: 'TaskPage',
  //   meta: {
  //     title: '任务管理',
  //     icon: 'task'
  //   },
  //   alwaysShow: true,
  //   children: [
  //     {
  //       path: 'list',
  //       component: () => import('@/views/task/list'),
  //       name: 'TaskListPage',
  //       meta: { title: '任务列表', noCache: true }
  //     },
  //     {
  //       path: 'edit',
  //       component: () => import('@/views/task/edit'),
  //       name: 'TaskEditPage',
  //       meta: { title: '任务创建', noCache: true }
  //     }
  //   ]
  // },
  // {
  //   path: '/education',
  //   component: Layout,
  //   name: 'EducationPage',
  //   meta: {
  //     title: '教育管理',
  //     icon: 'education'
  //   },
  //   alwaysShow: true,
  //   children: [
  //     {
  //       path: 'subject/list',
  //       component: () => import('@/views/education/subject/list'),
  //       name: 'EducationSubjectPage',
  //       meta: { title: '学科列表', noCache: true }
  //     },
  //     {
  //       path: 'subject/edit',
  //       component: () => import('@/views/education/subject/edit'),
  //       name: 'EducationSubjectEditPage',
  //       meta: { title: '学科编辑', noCache: true, activeMenu: '/education/subject/list' },
  //       hidden: true
  //     }
  //   ]
  // },
  {
    path: '/answer',
    component: Layout,
    name: 'AnswerPage',
    meta: {
      title: '成绩管理',
      icon: 'answer'
    },
    alwaysShow: true,
    children: [
      {
        path: 'list',
        component: () => import('@/views/answer/list'),
        name: 'AnswerPageList',
        meta: { title: '答卷列表', noCache: true }
      }
    ]
  },
  {
    path: '/message',
    component: Layout,
    name: 'MessagePage',
    meta: {
      title: '问题中心',
      icon: 'message'
    },
    alwaysShow: true,
    children: [
      {
        path: 'list',
        component: () => import('@/views/message/list'),
        name: 'MessageListPage',
        meta: { title: '问题列表', noCache: true }
      },
      {
        path: 'send',
        component: () => import('@/views/message/send'),
        name: 'MessageSendPage',
        meta: { title: '回答问题', noCache: true },
        hidden: true
      },
      {
        path: 'detail',
        component: () => import('@/views/message/detail'),
        name: 'MessageDetail',
        meta: { title: '问题回复', noCache: true },
        hidden: true
      }
    ]
  },
  {
    path: '/inform',
    component: Layout,
    name: 'InformPage',
    meta: {
      title: '消息中心',
      icon: 'list'
    },
    alwaysShow: true,
    children: [
      {
        path: 'list',
        component: () => import('@/views/inform/list'),
        name: 'InformListPage',
        meta: { title: '消息列表', noCache: true }
      },
      {
        path: 'UserList',
        component: () => import('@/views/inform/UserList'),
        name: 'findUserListPage',
        meta: { title: '发送消息', noCache: true }
      }
    ]
  },
  {
    path: '/log',
    component: Layout,
    name: 'LogPage',
    meta: {
      title: '日志中心',
      icon: 'log'
    },
    alwaysShow: true,
    children: [
      {
        path: 'user/list',
        component: () => import('@/views/log/list'),
        name: 'LogUserPage',
        meta: { title: '用户日志', noCache: true }
      }
    ]
  },
  {
    path: '/dictionary',
    component: Layout,
    name: 'DataPage',
    meta: {
      title: '数据字典管理',
      icon: 'task'
    },
    alwaysShow: true,
    children: [
      {
        path: 'list',
        component: () => import('@/views/dictionary/list'),
        name: 'DataListPage',
        meta: { title: '数据字典列表', noCache: true }
      },
      {
        path: 'edit',
        component: () => import('@/views/dictionary/edit'),
        name: 'DataEditPage',
        meta: { title: '数据字典创建', noCache: true }
      }
    ]
  },
  {
    path: '/profile',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'index',
        component: () => import('@/views/profile/index'),
        name: 'Profile',
        meta: { title: '个人简介', icon: 'user', noCache: true }
      }
    ]
  },
  { path: '*',
    hidden: true,
    component: () => import('@/views/error-page/404'),
    meta: { title: '404', noCache: true }
  }
]

const router = new Router({
  routes: constantRoutes
})

export {
  constantRoutes,
  router
}
